package org.loofer.ext.component.drawable;

import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import java.io.InputStream;

public class ResizeableBitmapDrawable extends BitmapDrawable {
    private int mHeight = -1;
    private int mWidth = -1;

    public ResizeableBitmapDrawable(Resources res, Bitmap bitmap) {
        super(res, bitmap);
    }

    public ResizeableBitmapDrawable(Resources res, InputStream is) {
        super(res, is);
    }

    public ResizeableBitmapDrawable(Resources res, String filepath) {
        super(res, filepath);
    }

    public void resize(int width, int height) {
        if (this.mWidth != width || this.mHeight != height) {
            this.mWidth = width;
            this.mHeight = height;
        }
    }

    public int getIntrinsicWidth() {
        return this.mWidth > 0 ? this.mWidth : super.getIntrinsicWidth();
    }

    public int getIntrinsicHeight() {
        return this.mHeight > 0 ? this.mHeight : super.getIntrinsicHeight();
    }
}
